package com.fourth.mapper;

import com.fourth.entity.BankCard;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 邓建波
 * @since 2022-08-04
 */
public interface BankCardMapper extends BaseMapper<BankCard> {

    /***
    *
     * 增加银行卡余额
     *
    *
     * @param cardId 银行卡号
     * @param amount 增加金额
     * @return: void 无返回
    */
    @Update("update tb_bank_card set card_balance = card_balance + #{amount} where card_id = #{cardId}")
    Boolean addCardBalance(@Param("cardId") String cardId, @Param("amount") BigDecimal amount);

    /***
     *
     * 扣除银行卡余额
     *
     *
     * @param cardId 银行卡号
     * @param amount 扣除金额
     * @return: void 无返回
     */
    @Update("update tb_bank_card set card_balance = card_balance - #{amount} where card_id = #{cardId}")
    boolean reduceBalance(@Param("cardId") String cardId, @Param("amount") BigDecimal amount);
}
